<template>
    <div>
        <div class="form-section">
            <div class="form-item  form-item-style1">
                <div class="label-title">
                    <label>验收名称</label>
                </div>
                <div>
                    <p>{{detailData.AcceptName}}</p>
                </div>
            </div>
            <div class="form-item form-item-style1">
                <div class="label-title">
                    <label>项目名称</label>
                </div>
                <div>
                    <p>{{detailData.AcceptName}}</p>
                </div>
            </div>
            <div class="form-item form-item-style1">
                <div class="label-title">
                    <label>项目经理</label>
                </div>
                <div>
                    <p>{{detailData.ItemManagerName}}</p>
                </div>
            </div>
            <div class="form-item form-item-style1">
                <div class="label-title">
                    <label>安全负责人</label>
                </div>
                <div>
                    <p>{{detailData.AqFzrName}}</p>
                </div>
            </div>
            <div class="form-item form-item-style2">
                <div class="label-title space-between">
                    <div class="space-between">
                        <label>验收人员</label>
                    </div>
                </div>
                <div>
                    <p class="textarea">{{detailData.AcceptPerNameList}}</p>
                </div>
            </div>
            <div class="form-item form-item-style1">
                <div class="label-title">
                    <label>验收日期</label>
                </div>
                <div>
                    <p>{{detailData.AcceptDate?detailData.AcceptDate.split(' ')[0]:''}}</p>
                </div>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>验收要求及检查结果</h3>
            <div v-for="(item,index) in detailData.dtConEleList"
                 :key="index">
                <div class="form-item  form-item-style1"
                     v-if="item.AcceptJg == '符合要求'">
                    <div class="label-title">
                        <label>{{item.AcceptYq}}</label>
                    </div>
                    <div>
                        <p>{{item.AcceptJg}}</p>
                    </div>
                </div>
                <div v-else>
                    <div class="form-item  form-item-style1">
                        <div class="label-title">
                            <label>{{item.AcceptYq}}</label>
                        </div>
                        <div style="display:flex;align-items: center;"
                             @click="openChild(item)">
                            <p>{{item.AcceptJg}}</p>
                            <x-icon type="ios-arrow-down"
                                    fill="#999"
                                    size="24"></x-icon>
                        </div>
                    </div>
                    <div class="form-item form-item-style2"
                         v-show="item.open">
                        <div class="label-title space-between">
                            <div class="space-between">
                                <label>存在的问题</label>
                            </div>
                        </div>
                        <div>
                            <p class="textarea">{{item.ExisProblems}}</p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-item form-item-style1">
                <div class="label-title">
                    <label>验收结论</label>
                </div>
                <div>
                    <p>{{detailData.IsPass}}</p>
                </div>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>附件信息</h3>
            <div class="form-item form-item-style1"
                 v-for="(item,index) in detailData.Files"
                 :key="index"
                 @click="preview(item.url)">
                <div class="label-title label-title1">
                    <label class="file-name">{{item.fileName}}</label>
                </div>
                <div class="right-section">
                    <span>预览</span>
                    <x-icon type="ios-arrow-right"
                            size="20"
                            class="icon-right"></x-icon>
                </div>
            </div>
        </div>
        <myMenu></myMenu>
    </div>
</template>
<script>
import myMenu from '@/commonComponents/menu'
export default {
    name: 'CEAcceptanceDetail',
    data () {
        return {
            regImg: /\.(png|jpg|PNG|JPG|jpeg|JPEG|gif|GIF)$/,
            userInfo: {},
            detailData: {}
        }
    },
    components: {
        myMenu
    },
    created () {
        this.userInfo = JSON.parse(localStorage.getItem('userInfo')) || {}
        this.getDetail()
    },
    methods: {
        preview (filePath) {
            if (this.regImg.test(filePath)) {
                this.$router.push({
                    path: '/previewImg',
                    query: {
                        previewImg: filePath
                    }
                })
            } else {
                wx.miniProgram.navigateTo({
                    url: `/pages/openDocument/index?filePath=${filePath}`
                })
            }
        },
        openChild (item) {
            this.$set(item, 'open', !item.open)
        },
        getDetail () {
            let params = {
                'allowPaging': true,
                'business': 'GetConEle',
                'data': {
                    'BusinessType': 2, // --业务类型参数 0：施工用电统计  1:施工用电查询 2:施工用电详细 3:存在问题
                    'CHECKNAME': '',
                    'CHECKTYPE': '',
                    'ID': this.$route.query.id
                },
                'pageIndex': 0,
                'pageSize': 0,
                'tokenId': '',
                'userId': this.userInfo.userid // -- - 用户ID
            }
            this.$axiosAjax.getConfigJson(params).then(res => {
                if (res.data.code === 0) {
                    this.detailData = res.data.data
                }
            }).finally(() => {
                this.$vux.loading.hide()
            })
        }
    }
}
</script>
<style scoped>
.file-name {
    white-space: nowrap;
    width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}
</style>
